'''
''' Override this method to filter the ${Second Dropdown List Control}DropDownList
''' based on the value selected for the ${First Dropdown List Control}DropDownList
'''
Protected Sub Populate${Second Dropdown List Control}DropDown(ByVal maxItems As Integer)
' Set up the WHERE clause.
' Create the WHERE clause to filter the second dropdown list based on
' the selected value of first dropdown list.
Dim wc As WhereClause = New WhereClause
Dim selectedValue As String = ${First Dropdown List Control}.SelectedValue
Dim selectedText As String = ${First Dropdown List Control}.SelectedItem.Text
wc.iAND(${${Table}ClassName}.${First Dropdown Field}, BaseFilter.ComparisonOperator.EqualsTo, selectedValue)
' Clear the contents of second dropdown list.
Me.${Second Dropdown List Control}.Items.Clear()
' Add "Please Select" string to the second dropdown list.
Me.${Second Dropdown List Control}.Items.Insert(0, New ListItem(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"), "--PLEASE_SELECT--"))
If (BaseClasses.Utils.StringUtils.InvariantUCase(selectedText).Equals(BaseClasses.Utils.StringUtils.InvariantUCase(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"))))
' if "Please Select" string is selected for first dropdown list,
' then do not continue populating the second dropdown list.
Return
End If
' Get the records using the created where clause.
Dim itemValue As ${${Table}RecordClassName}
For Each itemValue In ${${Table}ClassName}.GetRecords(wc, Nothing, 0, maxItems)
If (itemValue.${Second Dropdown Field}Specified)
' In each record, obtain the value of second dropdown field if value exists,
' create an item for it and add it to the list.
Dim cvalue As String = itemValue.${Second Dropdown Field}.ToString()
Dim fvalue As String = itemValue.Format(${${Table}ClassName}.${Second Dropdown Field})
Dim item As ListItem = New ListItem(fvalue, cvalue)
If (Not Me.${Second Dropdown List Control}.Items.Contains(item))
Me.${Second Dropdown List Control}.Items.Add(item)
End If
End If
Next
' Select "Please Select" string in the second dropdown list.
Me.${Second Dropdown List Control}.SelectedIndex = 0
End Sub
|